
import Element, { IObject3DMap } from '../State/Element';
import State from '../State';
import getObject3D from './getObject3D';

export default async function sceneRem(s: State, element?: Element<keyof IObject3DMap> | string) {
    if (!element) return;

    element = (typeof element === 'string') ? s.elementMap.get(element) : element
    if (!element) return

    const object3D = getObject3D(element)
    if (!object3D) return;

    s.scene?.remove(object3D);
    s.elementMap.delete(element.uuid);
    s.elementMap = new Map(s.elementMap);
}